package joney.main.preference;

import java.io.IOException;

import joney.main.Application;

import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.preferences.ScopedPreferenceStore;


/**
 * Base class to extend to add to preferences (resolves to Application scope preferences)
 * @author Sean McGrail
 *
 */
public abstract class DefaultPreferencePage extends FieldEditorPreferencePage 
implements IWorkbenchPreferencePage{
	
	protected ScopedPreferenceStoreMod preference; //saved values
	
	public DefaultPreferencePage(){
	super(GRID);
	preference = new ScopedPreferenceStoreMod(new ConfigurationScope(),Application.PLUGIN_ID);
	setPreferenceStore(preference);

		initDefaultValues();
	}
	
	//initi default prefs
	abstract void initDefaultValues();

	//override for apply button
	protected void performApply()
	{
		performOk();
		
		try {
			preference.save();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
